package com.controller;

import com.bean.Bumen;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
@RequestMapping("/consumer")
public class BumenController_Consumer {
    @Autowired
    private RestTemplate restTemplate;
    /*private static final String REST_URL="http://localhost:8001";*/
     private static final String REST_URL="http://microservicecloud-bumen";

    @RequestMapping(path = "/bumen/addbumen")
    public boolean addBumen(Bumen bumen){
      return  restTemplate.getForObject(REST_URL+"/bumen/addbumen",boolean.class,bumen);
    }
    @RequestMapping(path = "/bumen/list")
    public List<Bumen> getAll(){
        return restTemplate.getForObject(REST_URL+"/bumen/list",List.class);
    }
    @RequestMapping(path = "/bumen/getbumenbyid/{id}")
     public Bumen getBumenById(@PathVariable("id")Integer id ){
        return restTemplate.getForObject(REST_URL+"/bumen/getbumenbyid/"+id,Bumen.class);
    }

}
